#include<iostream>  
#include<vector>  
#include<algorithm>  
#include<climits>
#include<cmath>
#define int long long//这题会爆int(2147483648),必须开long long
using namespace std;  

const int N = 1e4 + 10;  
int n;  
int a[N];  
void solve() 
{  
    cin >> n;  
    for (int i = 1; i <= n; i++) cin >> a[i];  
    sort(a + 1, a + n + 1); 
    int sum1 = INT_MIN;  
    for(int i = 1; i <= n - 2; i++)
    {
        for(int j = i + 1; j <= n - 1; j++)
        {
            if(a[j + 1] >= a[i] + a[j]) continue;
            sum1 = max(sum1 , (a[i] + a[j] + a[j + 1]));
        }
    } 
    if (sum1 == INT_MIN) cout << "-1" << endl;  
    else cout << sum1 << endl;  
}  

signed main() {  
    ios::sync_with_stdio(0);  
    cin.tie(0), cout.tie(0);  
    int t;  
    cin >> t;  
    while (t--) solve();  
    return 0;  
}
/* #include<iostream>  
#include<vector>  
#include<algorithm>  
#include<climits>
#include<cmath>
#define int long long
using namespace std;  

const int N = 1e4 + 10;  
int n;  
int a[N];  
int sum[N];
void solve() 
{  
    cin >> n;  
    for (int i = 1; i <= n; i++) cin >> a[i];  
    sort(a + 1, a + n + 1); 
    int flag = 0;
    for(int i = n; i >= 3; i--)
    {
        if(a[i - 1] + a[i - 2] > a[i])
        {
            flag = 1;
            cout << a[i - 1] + a[i - 2] + a[i] << endl;
            break;
        }
    }
    if(!flag) cout << "-1" << endl;
}  
  
signed main() {  
    ios::sync_with_stdio(false);  
    cin.tie(0), cout.tie(0);  
    int t;  
    cin >> t;  
    while (t--) solve();  
    return 0;  
} */